2

vue实现a标签的锚点跳转功能

 <li @click="anchorJump">
            <span class="anchorEle">jump</span>
  </li>
 anchorJump() {
    const anchorEle = document.querySelector("#anchor");
    if (!!anchorEle ) {
      anchorEle .scrollIntoView(true);
    }
  }

document.querySelector("要返回地方的id").scrollIntoView(true);


MangoGoing
774 声望1.2k 粉丝

开源项目:详见个人详情